package com.csust.senior.dao.impl;

import com.csust.senior.dao.bankDao;
import com.csust.senior.dao.BaseDAO;

import java.sql.SQLException;

public class bankDAOImpl extends BaseDAO implements bankDao {

    @Override
    public int addBalance(int id, double balance) {
        try {
            String sql = "update t_bank set money = money + ? where id = ? ";
            return executeUpdate(sql,balance,id);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int subBalance(int id, double balance) {
//        return 0;
        try {
            String sql = "update t_bank set money = money - ? where id = ? ";
            return executeUpdate(sql,balance,id);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
